<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box{
            width: 300px;
            height: 300px;
            background-color: plum;
            margin: auto;
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <script>
        let box = document.querySelector('.box');
        console.log(box.offsetHeight);
        box.addEventListener('mouseover',function(e){
            // console.log(e.pageX)//得到当前X轴的偏移量
            // console.log(e.pageY)得到当前Y轴的偏移量

            let x = e.pageX - this.offsetLeft;
            let y = e.pageY - this.offsetTop;
            this.innerHTML = 'x'+x+'y'+y//获取鼠标在当前盒子的距离
        })
    </script>
</body>
</html>